<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
namespace app\index\route;

use app\index\middleware\AllowOriginMiddleware;
use app\index\middleware\UserTokenMiddleware;
use think\facade\Route;


Route::group(function (){
    //强制登录
    Route::group(function(){
        //用户信息

        Route::get('auth/userInfo', 'Auth/userInfo');//获取用户信息
        //页面
        Route::group('page/', function() {
            Route::get('userCenter', 'userCenterInfo');//个人中心页面
            Route::get('dianzhuang', 'dianzhuang');
            Route::get('carStatus', 'userCarStatus');//充电状态页面
            Route::get('memberInfo', 'memberInfo');//会员页面
        })->prefix('Index/');
        //充电桩
        Route::group('pile/', function() {
            Route::post('gun/firing', 'gunFiringCharge');//启动充电枪充电
            Route::post('gun/codeFiring', 'codeFiringCharge');//扫码启动充电枪充电
            Route::post('gun/deleteFiring', 'deleteFiring');//扫码启动充电枪充电
        })->prefix('ChargePile/');
        //订单
        Route::group('order/', function() {
            Route::post('select/status', 'selectOrderCharge');//查询订单是否开启充电
            Route::get('select/charge', 'getChargeOrderInfo');//查询充电订单状态
            Route::post('stop/charge', 'endChargingOrder');//结束充电
            Route::post('stop/status', 'selectOrderChargeStop');//查询订单是否结束充电
            Route::post('select/orderInfo', 'getOrderInfo');//查询订单详情
            Route::post('select/orderList', 'pileOrderList');//查询订单列表
            Route::post('orderPay', 'orderPay');//订单支付
            Route::post('pile/orderList', 'pileOrder');//订单支付
            Route::get('charge/orderStatus', 'chargeOrderStatus');//是否有充电订单
            Route::post('select/dianzhuanglist', 'dianzhuanglist');//查询电桩列表
            Route::post('select/dianzhuang', 'dianzhuang');//查询电桩订单
        })->prefix('Order/');
        //用户
        Route::group('user/', function() {
            Route::post('station/collect', 'collectStation');//用户充电站收藏操作
            Route::post('collect/list', 'collectList');//用户充电站收藏列表
            Route::post('car/listBind', 'userCarList');//用户绑定汽车列表
            Route::post('car/infoBind', 'userCarInfo');//用户绑定汽车内容
            Route::post('car/carBind', 'userBindCar');//用户绑定汽车
            Route::post('car/updateBind', 'updateBindCar');//用户更新绑定汽车
            Route::post('car/deleteBind', 'deleteUserCar');//删除绑定汽车
            Route::post('car/authentication', 'bindCarAuthentication');//车辆认证
            Route::post('user/uploadIcon', 'uploadUserImg');//上传头像
            Route::post('pwd/changePassword', 'changeUserPwd');//修改登录密码
            Route::post('pwd/payPwd', 'setPayPwd');//设置支付密码
            Route::post('info/update', 'saveUserInfo');//更改用户资料
            Route::post('myPile/list', 'myPile');//我的充电桩列表
            Route::post('userBill/list', 'userBill');//我的账号列表
            Route::post('community/list', 'community');//
            Route::post('Applytj/add', 'Applytj');//
            Route::post('user/tixian', 'tixian');//提现

            Route::post('user/tixianlist', 'tixianlist');//提现记录

            Route::post('user/nummoney', 'nummoney');//已提现金额



        })->prefix('User/');

        //用户获利
        Route::group('user/', function() {
            Route::post('myPile/monthProfit', 'userPileMonthProfit');//我的充电桩月度获利
            Route::post('myPile/dayProfit', 'userPileProfit');//我的充电桩日获利
            Route::post('profit/userDayProfit', 'getUserDayProfit');//我的充电桩当天获利
        })->prefix('UserProfit/');


        //用户充值
        Route::group('user/', function() {
            Route::post('recharge/list', 'getUserRecharge');//启动充电枪充电
            Route::post('recharge/recharge', 'addUserRecharge');//扫码启动充电枪充电
        })->prefix('UserRecharge/');


        //共用
        Route::group('common/', function() {
            Route::post('images/upload', 'uploadImg');//上传图片

        })->prefix('Common/');

        //退出登录
        Route::post('logout', 'Auth/logout');

    })->middleware(UserTokenMiddleware::class, true);

    //非强制登录
    Route::group(function () {
        //首页
        Route::group('page/', function() {
            Route::get('indexInfo', 'indexPageInfo');//首页页面
            Route::post('chargeStation', 'getChargeStation');//获取充电桩列表
            Route::post('findStation', 'findStationInfo');//找站页面
        })->prefix('Index/');

        //充电桩
        Route::group('pile/', function() {
            Route::post('station/details', 'stationDetails');//获取充电站详情
            Route::post('gun/details', 'gunDetails');//获取充电枪详情
            Route::post('station/infoByGun', 'getStationByGun');//充电枪获取充电站详情
            Route::post('details/info', 'getPileInfo');//充电桩详情
        })->prefix('ChargePile/');

        //车辆
        Route::group('car/', function() {
            Route::post('brand/getList', 'carBrandList');//汽车品牌列表
            Route::post('model/getList', 'carModelList');//汽车型号列表
        })->prefix('Car/');
        Route::post('auth/setLoginPassword', 'User/changePassword');//修改密码


        Route::get('/','Index/index')->name('IndexHome');
        Route::post('auth/getSms', 'Auth/getSms')->name('AuthGetSms');//获取验证码
        Route::post('auth/register', 'Auth/register')->name('AuthRegister');//用户注册
        Route::post('auth/login', 'Auth/login')->name('AuthLogin');//登录
        Route::get('auth/weChatAuth', 'Auth/weChatAuth')->name('weChatAuth');//获取微信授权信息
        Route::any('auth/wechat/back', 'Auth/weChatAuthBack')->name('weChatAuthBack');//获取微信授权回调路径
        Route::post('auth/bind/phone', 'Auth/bindUserRecord')->name('weChatAuthBindUserRecord');//微信公众号绑定手机号
        Route::post('auth/wechat/appletAuth', 'Auth/appletAuth')->name('weChatAppletAuth');//小程序授权登录，获取openid
        Route::post('auth/wechat/applePhone', 'Auth/getApplePhone')->name('weChatGetApplePhone');//小程序获取手机号
        Route::post('auth/wechat/appletBindPhone', 'Auth/appletBindPhone')->name('weChatAppletBindPhone');//小程序绑定手机号
        Route::get('weiXin/getWxConfig', 'Auth/getWxConfig')->name('getWxConfig');//获取微信有关配置

        //支付回调
        Route::any('wechat/apple/notifyUrl', 'Order/weChatAppleNotify')->name('weChatAppletNotifyUrl');//小程序支付充电订单回调
        Route::any('recharge/apple/notifyUrl', 'UserRecharge/weChatAppleNotify')->name('rechargeWeChatAppleNotify');//小程序支付充值回调
        Route::get('pay/type/list', 'Order/payTypeList')->name('payTypeList');//支付类型列表

        //订单定时器统计
        Route::get('order/timer/orderMoney', 'Order/orderMoneyTimer')->name('orderMoneyTimer');//订单金额统计-定时器
        Route::get('timer/order/orderSet', 'Timer/timerSet')->name('orderSetTimer');//订单设置，虚拟订单增加
        Route::get('timer/pile/timeAddPile', 'Timer/timeAddPile')->name('timeAddPile');//增加虚拟设备
        Route::get('timer/user/setUserData', 'Timer/setUserData')->name('timeSetUserData');//增加虚拟设备

        //第三方接口
        Route::group('ykc/', function() {
            Route::any('loginInfo', 'test')->name('YunKuaiChongLoginInfo');//云快充登录
            Route::any('selectStationInfo', 'selectStationInfo')->name('YunKuaiChongSelectStationInfo');//站点查询
            Route::any('selectDeviceInfo', 'selectDeviceInfo')->name('YunKuaiChongSelectDeviceInfo');//设备查询
            Route::any('query_token', 'queryToken')->name('YunKuaiChongQueryToken');//云快充设备状态变化推送
            Route::any('notification_stationStatus', 'putDeviceInfo')->name('YunKuaiChongPutDeviceInfo');//云快充设备状态变化推送
            Route::any('notification_charge_order_info', 'putOrderInfo')->name('YunKuaiChongPutOrder');//云快充获取订单信息
            Route::get('timeSelect', 'timeSelect')->name('YunKuaiTimeSelect');//云快充每分钟定时器
            Route::get('houseSelect', 'houseSelect')->name('YunKuaiHouseSelect');//云快充每小时定时器
        })->prefix('YunKuaiChong/');

        //pc端首页数据展示
        Route::get('third/station/getStationData', 'Common/getStationData')->name('commonGetStationData');//获取查询数据

        //测试
        Route::get('test','UserRecharge/weChatBackSet');

        //新增加定时器
        //Route::get('ykc/timer/newTimedExecution', 'YkcPileTime/index');//新增虚拟充电桩和虚拟订单

    });

})->middleware(AllowOriginMiddleware::class);

// 路由不存在
Route::miss(function() {
    //dd('无对应路由');
    return json()->data([
        'message'=>'当前接口不存在',
        'code'=>1,
        'data'=>[],
        'status'=>-100,
    ]);
    //Route::redirect('/');
});
